package edu.bit.water.controller;

import edu.bit.water.entity.MetaLimit;
import edu.bit.water.service.MetaLimitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/meta_limit")
public class MetaLimitController {

    @Autowired
    private MetaLimitService metaLimitService;

    @ResponseBody
    @RequestMapping(value = "/select", method=RequestMethod.GET)
    public Map<String, Object> queryLimit(String stNumber) {
        Map<String, Object> result = new HashMap<>();
        List<MetaLimit> list = metaLimitService.queryLimit(stNumber);
        result.put("rows", list);
        return result;
    }

    @ResponseBody
    @RequestMapping("/insert")
    public Map<String, Object> insertMetaLimit(MetaLimit metaLimit) {
        metaLimit.showContent();
        Map<String, Object> result = metaLimitService.insertMetaLimitService(metaLimit);
        return result;
    }

    /**
     * 删除metaLimit
     * author Page
     */
    @ResponseBody
    @RequestMapping("/delete")
    public Map<String, Object> deleteMetaLimit(@RequestBody List<String>metaLimit) {
        return metaLimitService.deleteMetaLimit(metaLimit);
    }

    @ResponseBody
    @RequestMapping("/update")
    public Map<String, Object> updateMetaLimit(MetaLimit metaLimit) {
        Map<String, Object> result = metaLimitService.updateMetaLimitService(metaLimit);
        return result;
    }
}
